package com.example.moviepro.service.impl;

import com.example.moviepro.entity.Movie;
import com.example.moviepro.mapper.MovieMapper;
import com.example.moviepro.service.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MovieServiceimpl implements MovieService {

    @Autowired
    private MovieMapper movieMapper;


    @Override
    public void addMovie(Movie movie) {
        movieMapper.addMovie(movie);
    }

    @Override
    public Movie findMovie(Movie movie) {
        return movieMapper.findMovie(movie);
    }

    @Override
    public int findMovieId(Movie movie) {
        return movieMapper.findMovieId(movie);
    }

    @Override
    public Movie findMovieById(int id) {
        return movieMapper.findMovieById(id);
    }

    @Override
    public void deleteMovie(int id) {
        movieMapper.deleteMovie(id);
    }

    @Override
    public List<Movie> getAllMovies() {
        return movieMapper.getAllMovies();
    }

    @Override
    public void updatePosterUrl(String posterUrl,Movie movie) {
        int id = movie.getId();
        movieMapper.updatePosterUrl(posterUrl, id);
    }

    @Override
    public String findfilenameByid(int id) {
        return movieMapper.findFilenameByid(id);
    }
}
